package com.soulkun.smarthome.ui.main.personal.viewmodel

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.soulkun.smarthome.logic.repository.ApiRepository
import soulkun.library.utils.logE

class AppMainPersonalViewModel: ViewModel() {

    val nicknameLiveData = MutableLiveData<String>()
    val usernameLiveData = MutableLiveData<String>()

    init {
        "ViewModel is Created".logE()
    }

    override fun onCleared() {
        super.onCleared()
        "ViewModel is Cleared".logE()
    }

    fun getUserInfo() {
        ApiRepository.getUserInfo(this){
            nicknameLiveData.value = it.data.nickName!!
            usernameLiveData.value = it.data.userName!!
        }
    }

    fun logout() = ApiRepository.logout()

}